﻿#region
using System;
using System.Windows.Forms;
using ComicsDownloader.Properties;

#endregion

namespace ComicsDownloader.Forms
{
    public partial class OptionForm : RootForm
    {
        public OptionForm()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (DesignMode || RunTimeChecker.IsRunTime == false)
                return;

            if (string.IsNullOrEmpty(Settings.Default.DownloadRoot))
                Settings.Default.DownloadRoot = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

            txtBrowse.Text = Settings.Default.DownloadRoot;
        }

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            if (fbdBrowse.ShowDialog() == DialogResult.OK)
                txtBrowse.Text = fbdBrowse.SelectedPath;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtBrowse.Text.Length == 0)
            {
                MessageBox.Show("저장 위치를 설정되지 않았습니다.");
                return;
            }

            Settings.Default.DownloadRoot = txtBrowse.Text;
            Settings.Default.Save();

            Close();
        }
    }
}